/**
 * 
 */
package com.zznode.client.wlanpolling.other;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.zznode.client.wlanpolling.R;
import com.zznode.client.wlanpolling.main.MainTabActivity;
import com.zznode.client.wlanpolling.test.PollTestResultActivity;
import com.zznode.client.wlanpolling.test.ResConfirmActivity;

/**
 * 
 *
 */
public class OthersActivity extends ListActivity {
	private static final String TITLE = "title";
	private static final String DESCTIPTION = "description";
	
	private List<Map<String, ?>> listMsgHistory = new ArrayList<Map<String, ?>>();
	private SimpleAdapter lvMsgHistorySimpleAdapter;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.others);
		
		initData();
		
		lvMsgHistorySimpleAdapter = new SimpleAdapter(this, listMsgHistory, R.layout.others_child,
				new String[]{TITLE, DESCTIPTION},
				new int[]{R.id.title, R.id.description});
		setListAdapter(lvMsgHistorySimpleAdapter);
	}

	private void initData() {
		Map<String, String> item = new HashMap<String, String>();
		
		item.put(TITLE, "附近热点");
		item.put(DESCTIPTION, "查看附近的热点信息");
		listMsgHistory.add(item);
		
		item = new HashMap<String, String>();
		item.put(TITLE, "信息补录");
		item.put(DESCTIPTION, "补录遗漏信息");
		listMsgHistory.add(item);
	
		item = new HashMap<String, String>();
		item.put(TITLE, "故障描述");
		item.put(DESCTIPTION, "填写故障描述");
		listMsgHistory.add(item);
		
		item = new HashMap<String, String>();
		item.put(TITLE, "巡检结果");
		item.put(DESCTIPTION, "查看巡检结果");
		listMsgHistory.add(item);
		
		item = new HashMap<String, String>();
		item.put(TITLE, "网站测速");
		item.put(DESCTIPTION, "执行网站测速");
		listMsgHistory.add(item);
		
		/*
		item = new HashMap<String, String>();
		item.put(TITLE, "网优核查");
		item.put(DESCTIPTION, "执行网优核查");
		listMsgHistory.add(item);
		*/
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		
		switch (position) {
		case 0: {
			//附近热点
			Intent i = new Intent(this, NeighbouringAPListTabActivity.class);
			startActivity(i);
		}
			break;
		case 1: {
			//信息补录
			Intent i = new Intent(this, ResConfirmActivity.class);
			startActivity(i);
		}
			break;
		case 2: {
			//故障描述
			Intent i = new Intent(this, BreakdownActivity.class);
			startActivity(i);
		}
			break;
		case 3: {
			//巡检结果
			//Intent i = new Intent(this, PollTestResultActivity.class);
			//startActivity(i);
			Intent i = new Intent(this, TestResultListActivity.class);
			startActivity(i);
		}
			break;
		case 4: {
			//网站测速
			Intent ftpIntent = new Intent(this, WebSpeedTestMainActivity.class);
			startActivity(ftpIntent);
		}
			break;
		case 5: {
			//TODO 网优核查
		}
			break;
			
		default:
			break;
		}
	}
	
	@Override
	public void onBackPressed() {
		if(getParent() instanceof MainTabActivity) {
			((MainTabActivity)getParent()).changeTabByTabIndex(0);
		} else {
			super.onBackPressed();
		}
	}
}
